@extends('edu.layouts.master')
@section('content')
    edu.topic.index.blade.php
    <div class="container" id="commentApp">
        <div class="card">
            <div class="card-header">
                <div>
                    贴子列表
                    <a href="{{route('edu.topic.create')}}" class="btn btn-light btn-sm float-right">发表</a>
                </div>
            </div>
            <div class="card-body">
                <ul class="list-group list-group-lg list-group-flush list my--4">
                    @foreach($topics as $topic)
                        <li class="list-group-item px-0">
                            <div class="row align-items-center">
                                <div class="col-auto">
                                    <!-- Avatar -->
                                    <a href="#!" class="avatar avatar-lg">
                                        <img src="{{$topic->user->icon}}" class="avatar-img rounded">
                                    </a>
                                </div>
                                <div class="col ml--2">
                                    <h4 class="card-title mb-1 name">
                                        <a href="{{route('edu.topic.show',$topic)}}">
                                            {{$topic['title']}}
                                        </a>
                                    </h4>
                                    {{--这个标签是用来判断当前用户是否登陆,如果登陆就展示,没有登陆就不展示--}}
                                    @auth()
                                        <p class="card-text small text-muted mb-1">
                                            {{$topic->user->name}} {{$topic->category->name}}
                                        </p>
                                    @endauth
                                    <p class="card-text small text-muted">
                                        <span class="fe fe-clock mr-1"></span> {{$topic->updated_at->diffForHumans()}}
                                        <span class="fe fe-thumbs-up mr-1"></span> {{$topic->zan_num}}
                                    </p>
                                </div>
                            </div> <!-- / .row -->
                        </li>
                    @endforeach
                </ul>
            </div>
            <div class="card-footer text-muted">
                {{$topics->links()}}
            </div>
        </div>
    </div>
@endsection
